package com.candy.sys.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.candy.common.result.R;
import com.candy.sys.entity.Menu;
import com.candy.sys.entity.Role;
import com.candy.sys.service.IMenuService;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import com.candy.common.controller.BaseController;
import io.swagger.annotations.Api;

/**
 * <p>
 * 菜单 前端控制器
 * </p>
 *
 * @author pxs
 * @since 2021-06-27
 */
@Api(tags="菜单")
@RestController
@RequestMapping("/sys/menu")
public class MenuController extends BaseController<IMenuService, Menu> {
	@ApiOperation(value = "新增")
	@PostMapping
	@Override
	public R save(@Validated @RequestBody Menu menu)
	{
		return R.success(baseService.save(menu));
	}

	@Override
	@ApiOperation(value = "列表")
	@GetMapping("/list")
	public R list(Menu menu)
	{
		QueryWrapper<Menu> queryWrapper = new QueryWrapper<>();
		queryWrapper.setEntity(menu);
		queryWrapper.lambda().orderByAsc(Menu::getOrderNum);
		IPage<Menu> pageModel = baseService.page(getPage(), queryWrapper);
		return R.success(pageModel);
	}
}
